package org.xbill.DNS;

import java.util.ArrayList;
import java.util.List;

public class SetResponse
{
  static final int CNAME = 4;
  static final int DELEGATION = 3;
  static final int DNAME = 5;
  static final int NXDOMAIN = 1;
  static final int NXRRSET = 2;
  static final int SUCCESSFUL = 6;
  static final int UNKNOWN;
  private static final SetResponse nxdomain;
  private static final SetResponse nxrrset;
  private static final SetResponse unknown = new SetResponse(0);
  private Object data;
  private int type;

  static
  {
    nxdomain = new SetResponse(1);
    nxrrset = new SetResponse(2);
  }

  SetResponse(int paramInt)
  {
    if ((paramInt < 0) || (paramInt > 6))
      throw new IllegalArgumentException("invalid type");
    this.type = paramInt;
    this.data = null;
  }

  SetResponse(int paramInt, RRset paramRRset)
  {
    if ((paramInt < 0) || (paramInt > 6))
      throw new IllegalArgumentException("invalid type");
    this.type = paramInt;
    this.data = paramRRset;
  }

  static SetResponse ofType(int paramInt)
  {
    Object localObject;
    switch (paramInt)
    {
    default:
      throw new IllegalArgumentException("invalid type");
    case 0:
      localObject = unknown;
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          return localObject;
          localObject = nxdomain;
        }
        localObject = nxrrset;
      }
      SetResponse localSetResponse = new SetResponse();
      localSetResponse.type = paramInt;
      localSetResponse.data = null;
      localObject = localSetResponse;
    }
  }

  void addRRset(RRset paramRRset)
  {
    if (this.data == null)
      this.data = new ArrayList();
    ((List)this.data).add(paramRRset);
  }

  public RRset[] answers()
  {
    RRset[] arrayOfRRset;
    if (this.type != 6)
      arrayOfRRset = null;
    while (true)
    {
      return arrayOfRRset;
      List localList = (List)this.data;
      arrayOfRRset = (RRset[])localList.toArray(new RRset[localList.size()]);
    }
  }

  public CNAMERecord getCNAME()
  {
    return ((CNAMERecord)((RRset)this.data).first());
  }

  public DNAMERecord getDNAME()
  {
    return ((DNAMERecord)((RRset)this.data).first());
  }

  public RRset getNS()
  {
    return ((RRset)this.data);
  }

  public boolean isCNAME()
  {
    int i;
    if (this.type == 4)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean isDNAME()
  {
    int i;
    if (this.type == 5)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean isDelegation()
  {
    int i;
    if (this.type == 3)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean isNXDOMAIN()
  {
    int i;
    if (this.type == 1)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean isNXRRSET()
  {
    int i;
    if (this.type == 2)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean isSuccessful()
  {
    int i;
    if (this.type == 6)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean isUnknown()
  {
    int i;
    if (this.type == 0)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public String toString()
  {
    String str;
    switch (this.type)
    {
    default:
      throw new IllegalStateException();
    case 0:
      str = "unknown";
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                return str;
                str = "NXDOMAIN";
              }
              str = "NXRRSET";
            }
            str = "delegation: " + this.data;
          }
          str = "CNAME: " + this.data;
        }
        str = "DNAME: " + this.data;
      }
      str = "successful";
    }
  }
}